#include "stm32f10x.h"

void IWDG_Init(uint16_t Time)
{
    // enable write access
    IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
    // configure psc lr 
    // Time = psc * (lr + 1) / 40
    IWDG_SetPrescaler(IWDG_Prescaler_256);
    IWDG_SetReload(Time * 40 / 256 -1);
    IWDG_ReloadCounter();
    // enable iwdg Time = psc * (lr + 1) / 40
    IWDG_Enable();

}

